package lanqiao;

public class 移动射击 {
    public static void main(String[] args) {
        int ahead = 3;
        int back = 4;
        int hurt = 10;
        int[] arr = {1,2,3};
        int[] blood = {4,3,2,1};
        int index_a = 0;
        for (int i = 1; i <arr.length && arr[i]<hurt; i++) {
            arr[i] = arr[i] + arr[i-1];
            index_a++;
        }
        for (int i = 1; i <blood.length ; i++) {
            blood[i] = blood[i]+blood[i-1];
        }
        int ans = index_a;
        int i =0;
        while (i<=index_a){
            int k = 0;
            while (k<back && arr[index_a]+blood[k]<=hurt){
                k++;
            }
            ans = Math.max(ans,i+k+1);
            i++;
        }
        System.out.println(ans);
    }
}
